﻿using System;

namespace BizElements.Core
{
    /// <summary>
    /// Indicates the state of entity in regard to data-source.
    /// </summary>
    public enum EntityState
    {
        /// <summary>
        /// Entity contains new data, which is not persisted on the data source.
        /// <p>The state is changed to <b>Synchronized</b> after the entity has been inserted.
        /// It may switch to <b>OutOfSync</b> after it has been inserted if some fields have remained un-synchronized.
        /// Typically, that will happen if auto-incremented value cannot be retrieved after the insert operation.</p>
        /// </summary>
        New,

        /// <summary>
        /// Entity is synchronized whith the data source. It contains the same data as the respective row in the database.
        /// <p>An entity is considered to be in sync with the database immediately after fetch, update or 
        /// insert operation has been executed. The state is changed to <b>OutOfSync</b> when the entity data is 
        /// changed or the referenced row is deleted from the database.</p>
        /// </summary>
        Synchronized,

        /// <summary>
        /// Entity references an existing row in the database, but the values are different.
        /// <p>An entity is marked as out-of-sync when the values of an entity fetched from the data-source 
        /// have been modified. The state is changed to <b>Synchronized</b> after the update operation has been executed.</p>
        /// </summary>
        OutOfSync,

        /// <summary>
        /// Indicates that the row referenced by entity has been deleted from the database.
        /// <p>Executing the update operation on deleted entiy will have no effect, since the row to be updated doesn't exist.</p>
        /// </summary>
        Deleted,

        /// <summary>
        /// Indicates that the row referenced by entity is to be deleted from the database.
        /// <p>An entity must be manually marked as deletion pending. The state is changed to <b>Deleted</b>
        /// after it has been deleted.</p>
        /// </summary>
        PendingDeletion
    }
}
